package com.itheima.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.itheima.bean.SetmealDish;
import com.itheima.dao.SetmealDishDao;
import com.itheima.service.SetmealDishService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class SetmealDishServiceImpl implements SetmealDishService {
    @Autowired
    private SetmealDishDao setmealDishDao;
    @Override
    public int add(SetmealDish setmealDish) {
        return setmealDishDao.insert(setmealDish);
    }

    @Override
    public List<SetmealDish> findBySid(Long id) {
        LambdaQueryWrapper<SetmealDish> lqw = new LambdaQueryWrapper<>();
        lqw.eq(SetmealDish::getSetmealId,id);
        return setmealDishDao.selectList(lqw);
    }

    @Override
    public int delete(Long id) {
        LambdaQueryWrapper<SetmealDish> lqw = new LambdaQueryWrapper<>();
        lqw.eq(SetmealDish::getSetmealId,id);
        return setmealDishDao.delete(lqw);
    }
}
